package com.broada.apm.indicator.api.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.broada.apm.dao.IndicatorDao;
import com.broada.apm.indicator.api.IndicatorItemService;
import com.broada.apm.model.DictMetrics;
import com.broada.apm.model.L7ModuelPanel;
import com.broada.apm.model.L7moduleMetric;

public class IndicatorItemServiceImpl implements IndicatorItemService {
	@Autowired
	private IndicatorDao indicatorDao;

	@Override
	public List<DictMetrics> listItems() {
		
		return indicatorDao.listItems();
	}

	@Override
	public List<L7ModuelPanel> getPanleIndicatorItemByProtocol(L7ModuelPanel panel) {
		return indicatorDao.getPanleIndicatorItemByProtocol(panel);
	}

	@Override
	public List<DictMetrics> getDictMetricsByProtocol(int l7protocol) {
		return indicatorDao.getDictMetricsByProtocol(l7protocol);
	}

	@Override
	public DictMetrics getItemById(int itemId) {
		return indicatorDao.getItemById(itemId);
	}
	
	@Override
	public DictMetrics getDictMetricsByCode(String code) {
		return indicatorDao.getDictMetricsByCode(code);
	}

	@Override
	public void addDictMetrics(DictMetrics dictMetrics) {
		indicatorDao.addDictMetrics(dictMetrics);
	}

	@Override
	public void addL7ModuleMetric(L7moduleMetric l7Metric) {
		indicatorDao.addL7ModuleMetric(l7Metric);
	}

	@Override
	public void addL7ModulePanel(L7ModuelPanel panel) {
		indicatorDao.addL7ModulePanel(panel);
	}

	@Override
	public List<L7moduleMetric> getL7ModuleMetric(L7moduleMetric l7Metric) {
		return indicatorDao.getL7ModuleMetric(l7Metric);
	}

	@Override
	public List<L7ModuelPanel> getL7ModulePanel(L7ModuelPanel panel) {
		return indicatorDao.getL7ModulePanel(panel);
	}

	@Override
	public List<L7moduleMetric> deleteMetricsByModuleId(String moduleId) {
		L7moduleMetric l7moduleMetric = new L7moduleMetric();
		l7moduleMetric.setModuleId(moduleId);
		List<L7moduleMetric> l7moduleMetricList = indicatorDao.getL7ModuleMetric(l7moduleMetric);
		indicatorDao.deleteMetricsByModuleId(moduleId);
		return l7moduleMetricList;
	}

	@Override
	public void updateDictMetrics(DictMetrics dictMetrics) {
		indicatorDao.updateDictMetrics(dictMetrics);
	}

	@Override
	public void updateL7ModuleMetric(L7moduleMetric l7Metric) {
		indicatorDao.updateL7ModuleMetric(l7Metric);
	}

	@Override
	public List<L7ModuelPanel> deleteL7PanelByModuleId(String moduleId) {
		L7ModuelPanel panel = new L7ModuelPanel();
		panel.setModuleId(moduleId);
		List<L7ModuelPanel> panelList = indicatorDao.getL7ModulePanel(panel);
		indicatorDao.deleteL7PanelByModuleId(moduleId);
		return panelList;
	}

	@Override
	public void updateL7ModulePanel(L7ModuelPanel panel) {
		indicatorDao.updateL7ModulePanel(panel);
	}

	@Override
	public List<L7moduleMetric> listItemsByCondition(L7moduleMetric conn) {
		return indicatorDao.listItemsByCondition(conn);
	}

	@Override
	public void updateResShowIndicator(String targetId, String panelId, List<Integer> metricIds) {
		indicatorDao.updateResShowIndicator(targetId, panelId, metricIds);
	}

	@Override
	public List<Integer> getResShowIndicator(String targetId, String panelId) {
		return indicatorDao.getResShowIndicator(targetId, panelId);
	}

}
